<template>
  <div class="container">
    <div class="header">
      <div class="header-left">
        <a href="javascript:;" @click="goBack" class="iconfont back-icon"
          >&#xe624;</a
        >
      </div>
      <div class="title">自助查询</div>
    </div>
    <div class="content">
      <div class="banner-quiry">
        <i class="icon-quiry"></i>
        <img src="@/assets/images/banner-quiry-bg.png" alt="" />
      </div>

      <div class="quiry-form">
        <input
          type="text"
          class="rep-number"
          placeholder="请输入举报编码"
          v-model="view_number"
          name=""
          id=""
        />
        <input
          type="password"
          class="rep-number"
          placeholder="请输入查询密码"
          v-model="view_password"
          id=""
        />
        <button @click="getReport">立即查看</button>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
export default {
  name: "inquiry",
  data() {
    return {
      view_number: "",
      view_password: ""
    };
  },
  created() {},
  beforeDestroy() {},
  methods: {
    goBack() {
      this.$router.go(-1);
    },
    getReport() {
      if (!this.view_number) {
        Toast("请输入查询编码");
        return false;
      }
      if (!this.view_password) {
        Toast("请输入查询密码");
        return false;
      }
      this.$axios
        .post("api/report/getReport", {
          view_number: this.view_number,
          view_password: this.view_password
        })
        .then(res => {
          if (res.data.status == 0) {
            console.log(res.data.result.message instanceof Array);
            if (res.data.result.message instanceof Array) {
              Toast(res.data.result.message[0][0]);
              return false;
            } else {
              Toast(res.data.result.message);
              return false;
            }
          }

          if (res.data.status == -1) {
            this.$router.push({ name: "inquiryFailure", params: {} });
            return false;
          }
          // console.log(res.data.result.reports)

          this.$router.push({
            name: "OnLineReport",
            params: {
              reports: res.data.result.reports
            }
          });
        });
    }
  }
};
</script>

<style lang="stylus" scoped>
.container {
  overflow: hidden;
  height: 100%;
}

.header {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  height: 0.44rem;
  line-height: 0.44rem;
  background: #256ccb;
  color: #fff;

  .header-left {
    width: 0.4rem;

    .back-icon {
      display: block;
      text-align: center;
      font-size: 0.17rem;
      font-weight: bold;
      color: #fff;
    }
  }

  .title {
    width: 100%;
    text-align: center;
    margin-right: 0.33rem;
    font-size: 0.17rem;
    font-weight: bold;
  }
}

.content {
  margin-top: 0.44rem;
  display: block;
  height: calc(100% - 0.44rem);
  overflow-y: auto;
 -webkit-overflow-scrolling : touch;
  .banner-quiry {
    width: 100%;
    position: relative;

    .icon-quiry {
      position: absolute;
      margin-top: 0.2rem;
      width: 100%;
      height: 60%;
      background: url('~@/assets/images/icon-quiry.png') center center no-repeat;
      background-size: contain;
    }

    img {
      width: 100%;
    }
  }

  .quiry-form {
    width: 100%;
    text-align: center;

    input, button {
      margin-top: 20px;
      height: 0.44rem;
      font-size: 16px;
      text-align: center;
      width: 90%;
      border-radius: 30rem;
    }

    button {
      margin-bottom: 20px;
      background-color: #f09330;
      color: white;
    }
  }
}
</style>
